import { Request, Response, NextFunction } from 'express'

const errorMiddleware = (err: any, req: Request, res: Response, next: NextFunction): void => {
  console.error(err);
  res.status(500).json({
    message: 'Internal Server Error',
    stack: process.env.NODE_ENV === 'development' ? err.stack : undefined,
  });
  return;
}

export default errorMiddleware;